function huoqu(time){
    var date = new Date(time)
    var cdate = date.getTime()
    console.log(cdate/1000)
    var dqDate = new Date().getTime()
    console.log(dqDate/1000)
    console.log()
    if((dqDate/1000)-(cdate/1000)<=0){
       return
    }
    if((dqDate/1000)-(cdate/1000)<=1){
        document.querySelector('h1').innerHTML = date+'刚刚'
    }else if((dqDate/1000)-(cdate/1000)<=15){
        document.querySelector('h1').innerHTML =  date+'几秒前'
    }
    else if((dqDate/1000)-(cdate/1000)<=60){
        document.querySelector('h1').innerHTML =  date+'一分钟前'
    }
    else if((dqDate/1000)-(cdate/1000)<=600 &&(dqDate/1000)-(cdate/1000)>60){
        document.querySelector('h1').innerHTML =  date+'几分钟前'
    }
    else if((dqDate/1000)-(cdate/1000)>=600 &&(dqDate/1000)-(cdate/1000)<=3600){
        document.querySelector('h1').innerHTML =  date+'十几分钟前'
    }
    else if((dqDate/1000)-(cdate/1000)>=3600&&(dqDate/1000)-(cdate/1000)<=36000){
        document.querySelector('h1').innerHTML =  date+'几小时前'
    }else{
        document.querySelector('h1').innerHTML =  date
    }
}

 //判断浏览器内核
function browserData() 
{
    var u = navigator.userAgent;
    return {
        trident: u.indexOf('Trident') > -1, //IE内核
        presto: u.indexOf('Presto') > -1, //opera内核
        webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
        gecko: u.indexOf('Firefox') > -1, //火狐内核Gecko
        mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
        ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios
        android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android
        iPhone: u.indexOf('iPhone') > -1 , //iPhone
        iPad: u.indexOf('iPad') > -1, //iPad
        webApp: u.indexOf('Safari') > -1 //Safari
    }
}

// 3 现在是PC还是移动 

function isM()
{
    var browser = {
        versions: function() {
          var u = navigator.userAgent;
          return {
                  mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
                  ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios
                  android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android
                  iPhone: u.indexOf('iPhone') > -1 , //iPhone
                  iPad: u.indexOf('iPad') > -1, //iPad
                  webApp: u.indexOf('Safari') > -1 //Safari
              };
          }
      }
      if (browser.versions.mobile || browser.versions.ios || browser.versions.android || browser.versions.iPhone || browser.versions.iPad) {
        // alert('移动端');
        return true
      } else {
        // alert('PC')
        return false
      }
}

// 4 判断是否是微信浏览器

function isWx()
{
    var ua = navigator.userAgent.toLowerCase();
    if(ua.match(/MicroMessenger/i)=="micromessenger") {
        return true;
    } else {
        return false;
    }
}



// 5 获取地址栏参数
/**
 * 获取地址栏参数
 * @param {string} key 
 */
function getParams(key){
    let query = window.location.search.substring(1)
    query = decodeURI(query)
    let vars = query.split('&')
    for(var i=0;i<vars.length;i++){
        var tempArr = vars[i].split('=')
        if(tempArr[0] == key) return tempArr[1]
    }
    return false
}